<?php
global $_RQ,$_AR;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
$item=$this->plugin_setting('setting');
$return['adv']=$item['hdps'];
if($_RQ['op']=='main'){
	$setting=$this->plugin_setting('setting');
	$return['groups']=pdo_getall('jy_cms360_group',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),'','','paixu desc');
	$return['list']=array();
	$return['setting']=$setting;
	$_SESSION['keyword']=$_RQ['keyword'];
	exi($return);
}
if($_RQ['op']=='list'){
	$postdata=get_postdata();
	$pindex = max(1, intval($postdata['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'status'=>1);
	if($_SESSION['keyword']){
		$params['title like']='%'.trim($_SESSION['keyword']).'%';
	}
    $fields=array('id','title','image','likenum','url','paixu','readnum','ishome','ishot');
    $orderby='paixu desc';
	$total='';
	$return['groups']=pdo_getall('jy_cms360_group',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),'','','paixu desc');
	$return['list']=pdo_getslice('jy_cms360_list',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if($id){
		exi('请选择全景','error','/list/');
	}
	$return['detail']=pdo_get('jy_cms360_list',array('id'=>$id));
	exi($return);
}
if($_RQ['op']=='comments'){
	$id=intval($_RQ['id']);
	if($id){
		exi('请选择全景','error','/list/');
	}
	$postdata=get_postdata();
	$data=array_fields(array('type','content'),$postdata);
	$data['uid']=$_SESSION['uid'];
	$data['uniacid']=$_SESSION['uniacid'];
	$data['cid']=$id;
	$data['status']=1;
	pdo_insert('jy_cms360_comments',$data);
	exi('评论成功','','/list/detail');
	}
if($_RQ['op']=='like'){
	$id=intval($_RQ['id']);
	if($id){
		exi('请选择全景','error','/list/');
	}
	$like=pdo_get('jy_cms360_like',array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uniacid'],'cid'=>$id));
	if(empty($like)){
		$data=array('uniacid'=>$_SESSION['uniacid'],'uid'=>$_SESSION['uniacid'],'cid'=>$id);
		pdo_insert('jy_cms360_like',$data);
		exi('点赞成功','','/list/detail');
	}else{
		pdo_delete('jy_cms360_like',$data);
		exi('取消点赞成功','','/list/detail');
	}
	
	}
?>